package com.gitee.cirnochat.common.event.listener;

import com.gitee.cirnochat.common.event.EmailSendEvent;
import com.gitee.cirnochat.common.service.EmailService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class EmailSendListener {

    private final EmailService emailService;

    /**
     * 监听邮件发送事件
     * @param event 邮件发送事件
     */
    @EventListener(classes = EmailSendEvent.class)
    public void handleEmailSendEvent(EmailSendEvent event) {
        emailService.sendCaptchaAsync(event.getEmail(), event.getEmailSendType());
    }
}
